﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Windows.Controls;
using CommomFunctions;
using System.Windows;

namespace Filas
{
    public class Controls : CommomFunctions.Controls
    {
        /// <summary>
        /// queueElements -> the rectangles that will represent the elements in the queue
        /// queueImages -> all the images requiered
        /// elemLables -> each element in the queue has a label to differ it from other elements
        /// </summary>        
        protected static Rectangles queueElements = new Rectangles();
        protected static Images queueImages = new Images(queueElements.numElements);
        protected static Labels elemLabels = new Labels();
                
        public Controls()
        {

        }

        /// <summary>
        /// Adds to "gridi" the controls that were not declared/created in the xaml file.
        /// </summary>
        /// <param name="gridi">
        /// The application Grid where the controls are added.
        /// </param>
        public void addOtherControls(Grid Gridi)
        {
            gd = Gridi;

            elemLabels.createLabels(gd, queueElements.numElements);
            Animations.createAnimations(gd);
            queueImages.createControlImages(gd);           
            queueElements.createRectangles(gd, queueImages);

            createTrace(1, 3, 3, 3, new Thickness(15, 0, 15, 10), 230, 270);
            createLogo(7, 2, new Thickness(0, 30, 5, 5));
            createTitle("Manipulação de Filas", 1, 4, new Thickness(0, 5, 0, 0));
        }

        /// <summary>
        /// Updates the images, rectangles and labels size and position when the grid size changes
        /// </summary>
        public void gridSizeChanged()
        {
            queueImages.gridSizeChanged();
            queueElements.gridSizeChanged();
            elemLabels.gridSizeChanged(queueElements.numElements);
        }

        /// <summary>
        /// Calls the respective button function
        /// </summary>
        /// <param name="bc"></param>
        public void buttonClicked(ButtonClicked bc)
        {
            switch (bc)
            {
                case ButtonClicked.Create: Buttons.btnCreate_Click(btns);
                    break;
                case ButtonClicked.Destroy: Buttons.btnDestroy_Click(btns);
                    break;
                case ButtonClicked.Insert: Buttons.btnInsert_Click();
                    break;
                case ButtonClicked.Remove: Buttons.btnRemove_Click(btns);
                    break;                
            }
        }

    }
}
